package com.atguigu.guli.service.ucenter.controller.api;


import com.atguigu.guli.service.ucenter.service.MemberService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;



@Controller
@RequestMapping("/api/ucenter/wx")
public class ApiWxController {


    @Autowired
    MemberService memberService;
    @GetMapping("login")   //将需要的参数插入url，然后返回给前端就可以，回调地址需要转为utf-8类型的
    public String login(HttpSession session){
        String url = memberService.wxlogin(session);
        return url;
    }
    @GetMapping("callback")  //会自动调用改地址的方法，url后面？跟着的参数为code，state
    public String callback(String code, String state,HttpSession session){
        String token = memberService.callback(code,state,session);
        return token;
    }
}
